package com.murfrosoft.views;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Point;
import android.graphics.PointF;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnTouchListener;

public class TouchView extends View implements OnTouchListener{

	PointF p=new PointF();
	
	public TouchView(Context context) {
		super(context);
		setOnTouchListener((OnTouchListener) this);
		// TODO Auto-generated constructor stub
	}

    

	@Override
	protected void onDraw(Canvas canvas) {
		// TODO Auto-generated method stub
		super.onDraw(canvas);
		Paint pt=new Paint(Color.RED);
		Paint pt2 = new Paint(Color.MAGENTA);
		pt.setColor(Color.RED);
		pt.setAntiAlias(true);
		if( p.x > 0 && p.y > 0 ){
		  //canvas.drawCircle(p.x, p.y, 20, pt);
		  //canvas.drawRect(p.x-30, p.y+20,p.x+30, p.y+40, pt2);
		  //canvas.drawText("Bad Touch!", p.x-20, p.y+50, pt);
		  /* Draw a star?? */
			int size = 200;
			for( int i = 0; i <= size; i += 5 ){
				canvas.drawLine(p.x, p.y+i-size, p.x+i, p.y, pt);
				canvas.drawLine(p.x-size+i, p.y, p.x, p.y-i, pt);
				canvas.drawLine(p.x-size+i, p.y, p.x, p.y+i, pt);
				canvas.drawLine(p.x, p.y+i, p.x-i+size, p.y, pt);
				/* BEHOLD THE POWER OF SOME THINGS MICHAEL CAN DO!!! */
			}
		}
	}



	@Override
	public boolean onTouch(View v, MotionEvent event) {
		// TODO Auto-generated method stub
		p.x=event.getX();
		p.y=event.getY();
		invalidate();
		return false;
	}


	
	

}
